package com.ruoyi.appService.mbtiTest.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.appService.mbtiTest.domain.ZTestMbti;
import com.ruoyi.appService.mbtiTest.service.IZTestMbtiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * mbti测试Controller
 * 
 * @author anjiao
 * @date 2025-05-10
 */
@RestController
@RequestMapping("/mentalTest/mbtiTest")
public class ZTestMbtiController extends BaseController
{
    @Autowired
    private IZTestMbtiService zTestMbtiService;

    /**
     * 查询mbti测试列表
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:mbtiTest:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZTestMbti zTestMbti)
    {
        startPage();
        List<ZTestMbti> list = zTestMbtiService.selectZTestMbtiList(zTestMbti);
        return getDataTable(list);
    }

//    查询所有测试题
@GetMapping("/listAll")
public TableDataInfo listAll(ZTestMbti zTestMbti)
{
    List<ZTestMbti> list = zTestMbtiService.selectZTestMbtiList(zTestMbti);
    return getDataTable(list);
}



    /**
     * 导出mbti测试列表
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:mbtiTest:export')")
    @Log(title = "mbti测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZTestMbti zTestMbti)
    {
        List<ZTestMbti> list = zTestMbtiService.selectZTestMbtiList(zTestMbti);
        ExcelUtil<ZTestMbti> util = new ExcelUtil<ZTestMbti>(ZTestMbti.class);
        util.exportExcel(response, list, "mbti测试数据");
    }

    /**
     * 获取mbti测试详细信息
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:mbtiTest:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zTestMbtiService.selectZTestMbtiById(id));
    }

    /**
     * 新增mbti测试
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:mbtiTest:add')")
    @Log(title = "mbti测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZTestMbti zTestMbti)
    {
        return toAjax(zTestMbtiService.insertZTestMbti(zTestMbti));
    }

    /**
     * 修改mbti测试
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:mbtiTest:edit')")
    @Log(title = "mbti测试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZTestMbti zTestMbti)
    {
        return toAjax(zTestMbtiService.updateZTestMbti(zTestMbti));
    }

    /**
     * 删除mbti测试
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:mbtiTest:remove')")
    @Log(title = "mbti测试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zTestMbtiService.deleteZTestMbtiByIds(ids));
    }
}
